package cn.xaut.数组;

public class demo345 {

    static boolean isNotVowel(char c) {
        return c != 'a' && c != 'e' && c != 'i' && c != 'o' && c != 'u'
                && c != 'A' && c != 'E' && c != 'I' && c != 'O' && c != 'U';
    }
    
    public String reverseVowels(String s) {

        char[] cs = s.toCharArray();
        int l = 0, r = s.length() - 1;
        while (r > l) {
            while (r > l && isNotVowel(cs[l]))
                l ++;
            while (r > l && isNotVowel(cs[r]))
                r --;
            char t = cs[r];
            cs[r] = cs[l];
            cs[l] = t;
            l ++;
            r --;
        }
        
        return String.copyValueOf(cs);
    }

    public static void main(String[] args) {

        System.out.println(new demo345().reverseVowels("hello"));//holle
        System.out.println(new demo345().reverseVowels("leetcode"));//leotcede
    }
}
